import React,{PropTypes} from 'react'
import {connect} from 'react-redux'
import RComponent from '../../components'
import styles from './home.scss'
import Loading from '../../components/Loading'
import {getUserConfigure} from '../../actions/credentials.js'
import * as auth from '../../utils/auth'

class Home extends RComponent {
    // static fetchUserConfigire(param,store,url){
    //     console.log('state:'+JSON.stringify(store.getState()))
    //     return store.dispatch(getUserConfigure());
    // }

    constructor(props, context){
        super(props, context)
    }

    componentWillMount(){
        // this.setState({
        //     loading:true
        // })
        // this.props.dispatch(getUserConfigure());
    }

    componentDidMount(){
        const { loading,loaded,configureStatus } = this.props;
        if(auth.getUserConfigure() == '1')
            this.context.router.push('assetsConfig')
        }else{
            this.context.router.push('guideline')
        }
        // console.log('loading:'+loading)
    }

    render(){
        const { loading,loaded,configureStatus } = this.props;
        // console.log('loading:'+loading)
        // if(configureStatus == '1'){
        //     this.context.router.push('/modules/assetsConfig')
        // }else{
        //     this.context.router.push('/modules/guideline')
        // }
        return (
            <Loading loading={loading}>
                <div className="home">
                </div>
            </Loading>
        )
    }
}
Home.propTypes = {
    loading:PropTypes.bool,
    configureStatus:PropTypes.string,
}
Home.defaultProps = {
    loading:false,
    configureStatus:'0',
}

export default connect(
    (state) => {
        return {
            loading:state.page.loading,
            loaded:state.page.loaded,
            configureStatus:state.credentials.configureStatus
        }
    }
)(Home)
